package com.alita.redis.controller;

import com.alita.redis.service.RedisService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/redis")
public class RedisScanController {

    @Autowired
    private RedisService redisService;

    /**
     * /redis/scan/*:total:*
     * @param matchKey
     * @return
     */
    @GetMapping("/scan/{matchKey}")
    public String testScan(@PathVariable String matchKey){
        redisService.scanKey(matchKey);
        return "OK";
    }

    @GetMapping("/ttl/{key}")
    public String testTtl(@PathVariable String key){
        return redisService.ttl(key).toString();
    }



}
